<template>
	<view class="container bg-w">
		<view class="header uni-flex uni-row flex-between">
			<uni-nav-bar title="资料详情">
				<template slot='left'>
					<view class="flex width-100">
						<i class='iconfont iconfanhui' @click='goBack()'></i>
					</view>
				</template>
			</uni-nav-bar>
		</view>
		<view class="basic-information position-r-top">
			<uni-list>
				<view class="project-overview">
					<uni-list-item  title="资料名称" :rightText="datamanagementInfoList.dataName"></uni-list-item>
					<uni-list-item  title="资料类型" :rightText="datamanagementInfoList.dataType"></uni-list-item>
					<uni-list-item  title="日期" :rightText="datamanagementInfoList.createTime"></uni-list-item>
					<uni-list-item  title="附件" link showArrow='false' @click="fileOnlode">
						<template slot='footer'>
							<view class="theme-color margin-r-15">{{datamanagementInfoList.fileName}}</view>
						</template>
					</uni-list-item>
					<uni-list-item  title="备注" :rightText="datamanagementInfoList.remarks"></uni-list-item>
				</view>
			</uni-list>
		</view>
	</view>
</template>

<script>
	import { 
		datamanagementInfo,
		queryListByFieldType,
		getFileInfo,
		getFileInfoAll
	} from '@/common/api/api.js'
	import ipConfig from '@/utils/ipConfig.js'
	export default {
		data() {
			return {
				datamanagement:[],
				datamanagementInfoList:{}
			}
		},
		onLoad(option) {
			datamanagementInfo(option.dataId).then(res => {
				this.datamanagementInfoList = res.data
				queryListByFieldType('material_file').then(res => {
					res.data.forEach(obj => {
						if(this.datamanagementInfoList.type == JSON.parse(obj.value)){
							this.$set(this.datamanagementInfoList,'dataType',obj.label)
						}
					})
				})
				getFileInfoAll(this.datamanagementInfoList.attachmentId).then(res => {
					this.$set(this.datamanagementInfoList,'fileName',res.data.original)
				})
			})
		},
		methods: {
			fileOnlode(){
				if(this.datamanagementInfoList.attachmentId){
					plus.runtime.openURL(ipConfig.ip + 'admin/sys-file/getFileById?id='+this.datamanagementInfoList.attachmentId, function(res) {  
					  console.log(res);  
					});
				}else{
					uni.showToast({
						title:'暂无数据',
						icon:'none'
					})
				}
			},
		}
	}
</script>

<style>
 .project-overview /deep/ .uni-icon-wrapper{display: none;}
</style>
